home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: Need help on using ODBC databased from Visual C++
- Date: 31 Jan 1996 18:14:34 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4eobia$nv9@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe4.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 31, 1996 16:49:41 in article <Need help on using ODBC databased from
- Visual C++>, 'bassett@tenet.edu' wrote:
-
-
- >We what to open a MicroSoft Access database with more than one table in
- >it. We want to open the database once but open and close the various
- >tables in the database. How is this done. Currently we are able to access
-
- >the various tables in our database using the ODBC drivers that come with
- >Visual C++ 1.5 but when we do a database close it closes the entire
- >database where we just want to close the particular table in the
- >database. HELP.
- >
- I'm only familiar with MFC's ODBC classes in versions 2.2 and above, but
- chances are that it's the same in 1.5x.
-
- What I normally do is insert a CDatabase object as a member of
- my application class:
- CMyWinApp : public CWinApp
- { .....
- CDatabase mydb;
- public:
- CDatabase * GetDb() { return &mydb; }
- ....
-
- Define a global function for convenience:
-
- CDatabase * GetDatabase()
- { return ((CMyApp*)AfxGetApp())->GetDb(); }
-
- Then, I open it in my InitInstance for the application.
-
- When creating instances of CRecordset-derived classes, pass
- the database pointer as the optional arg:
-
- CMyRecordset rs(GetDatabase());
-
- That should do it.
-
- WARNING! All sample code typed in from memory. May contain
- minor errors.
-
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-